//
//  BCQrImagePickerViewController.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2019/1/14.
//  Copyright © 2019 guoshikeji. All rights reserved.
//

#import "BCQrImagePickerViewController.h"

//
#import "BCPutCoinQrIdentificationController.h"

@interface BCQrImagePickerViewController () <BCPutCoinQrIdentificationControllerDelegate>

@end

@implementation BCQrImagePickerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
}



/**
 *  cell 被点击时调用（先调用这个接口，然后才去走预览大图的逻辑），注意这并非指选中 checkbox 事件
 *
 *  @param imagePickerViewController        对应的 QMUIImagePickerViewController
 *  @param imageAsset                       被选中的图片的 QMUIAsset 对象
 *  @param imagePickerPreviewViewController 选中图片后进行图片预览的 viewController
 */
- (void)imagePickerViewController:(QMUIImagePickerViewController *)imagePickerViewController didSelectImageWithImagesAsset:(QMUIAsset *)imageAsset afterImagePickerPreviewViewControllerUpdate:(QMUIImagePickerPreviewViewController *)imagePickerPreviewViewController {
    UIImage *originalImage = [imageAsset originImage];
    if (originalImage) {
        [self toIdentificationImage:originalImage];
    }
}

/**
 去识别二维码
 */
- (void)toIdentificationImage:(UIImage *)image {
    BCPutCoinQrIdentificationController *vc = [BCPutCoinQrIdentificationController new];
    vc.qrImage = image;
    vc.delegate = self;
    [self.navigationController pushViewController:vc animated:true];
}

#pragma mark - BCPutCoinQrIdentificationControllerDelegate
- (void)recognitionedValidAddress:(NSString *)address {
    if (self.addressDelegate && [self.addressDelegate respondsToSelector:@selector(recognitionedValidAddress:)]) {
        [self.addressDelegate recognitionedValidAddress:address];
    }
}

@end
